import { http } from '@/utils/http';
import type { Book } from './index.d';

export { Book };

/** 获取部分图书 */
export const getPartBookListApi = () => {
	return http<Book.BookItem[]>({
		url: `/api/book/part_book_list`,
		method: 'POST',
	});
};

/**  获取用户书架列表 */
export const getBookList = (data: Book.BookListParams) => {
	return http<Book.BookListData[]>({
		url: `/api/bookself/teacher_bookself_list`,
		method: 'POST',
		data,
	});
};

/**  删除用户书架 */
export const delBook = (data: Book.DelParams) => {
	return http({
		url: `/api/bookself/del_teacher_bookself`,
		method: 'POST',
		data,
	});
};

/**  获取荐书列表 */
export const getRecommendBookList = (data: Book.RecommendParams) => {
	return http<Book.RecommendData>({
		url: `/api/book/book_list`,
		method: 'POST',
		data,
	});
};

/**  获取专家荐书分类和年级 */
export const getRecommendClassifyGrade = () => {
	return http<Book.RecommendCGData>({
		url: `/api/book/book_classify_grade`,
		method: 'POST',
	});
};

/** 获取图书资源数据 */
export const getBookResource = (data: Book.ResourceParams) => {
	return http<Book.ResourceData>({
		url: `/api/book/book_resource_list`,
		method: 'POST',
		data,
	});
};

/** 获取图书详情 */
export const getBookDetails = (data: Book.BookDetailsParams) => {
	return http<Book.BookDetailsData>({
		url: `/api/book/book_info`,
		method: 'POST',
		data,
	});
};

/**  添加图书到书架 */
export const setBookSelf = (data: Book.BookDetailsParams) => {
	return http({
		url: `/api/book/add_book_self`,
		method: 'POST',
		data,
	});
};

/**  获取书籍试卷数据 */
export const getPaperInfo = (data: Book.PaperParams) => {
	return http<Book.PaperData>({
		url: `/api/bookexam/teacher_get_paper_info`,
		method: 'POST',
		data,
	});
};

/**  获取学生试卷完成情况 */
export const getPaperDetails = (data: Book.PaperDetailsParams) => {
	return http<Book.PaperDetailsData>({
		url: `/api/teacher/class_student_exam_record`,
		method: 'POST',
		data,
	});
};

/**  获取教师任教班级 */
export const getTeachClass = () => {
	return http<Book.TeacherClass[]>({
		url: `/api/teacher/class`,
		method: 'POST',
	});
};
